package cn.good.yan.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;

/**
 * 订单实体 - 测试多表关联  - 订单详情表
 *
 * @author shengren.yan
 * @create 2024/12/12
 */
@TableName("t_order_item")
@Data
@ToString
public class OrderItem {

    // 当配置了shardingsphere-jdbc的分布式序列时，自动使用shardingsphere-jdbc的分布式序列
    @TableId(type = IdType.AUTO)
    private Long id;
    private String orderNo;    // 订单编号
    private Long userId;
    private BigDecimal price;  // 价格
    private Integer count;     // 数量

}

/**
 * 测试水平分库:
 * sql:
 * CREATE TABLE `t_order_item0` (
 *  `id` bigint NOT NULL,
 *  `order_no` varchar(30) DEFAULT NULL,
 *  `user_id` bigint DEFAULT NULL,
 *  `price` decimal(10,2) DEFAULT NULL,
 *  `count` int DEFAULT NULL,
 *  PRIMARY KEY (`id`)
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
 * ----
 * CREATE TABLE `t_order_item1` (
 *  `id` bigint NOT NULL,
 *  `order_no` varchar(30) DEFAULT NULL,
 *  `user_id` bigint DEFAULT NULL,
 *  `price` decimal(10,2) DEFAULT NULL,
 *  `count` int DEFAULT NULL,
 *  PRIMARY KEY (`id`)
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
 */